package com.taobao.server.impl;

import java.util.ArrayList;
import java.util.List;

import com.taobao.dao.HistoryTaskDao;
import com.taobao.dao.PreHistoryTaskDao;
import com.taobao.dao.ReceiveLastOneDBDao;
import com.taobao.dao.ReceiveSaveDBDao;
import com.taobao.pojo.Task;
import com.taobao.server.CommonServer;
import com.taobao.server.HistoryServer;

public class HistoryServerImpl extends CommonServer implements HistoryServer {

	private PreHistoryTaskDao preHistoryTaskDao;
	private HistoryTaskDao historyTaskDao;
	private ReceiveSaveDBDao receiveSaveDBDao;
	private ReceiveLastOneDBDao receiveLastOneDBDao;

	@Override
	public List<Task> getReceiveHistory() {
		List<Task> tasks = new ArrayList<Task>();
		try {
			String[] ve = preHistoryTaskDao.preHistorySerach();
			Task last = receiveLastOneDBDao.getLastTask();
			tasks = historyTaskDao.historySerach(ve, last);
			receiveSaveDBDao.saveTasks(tasks);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return tasks;
	}

	@Override
	public List<Task> getPublishHistory() {
		// TODO Auto-generated method stub
		return null;
	}

}
